package com.woniuxy.carrental.service.impl;

import com.woniuxy.carrental.entity.Contract;
import com.woniuxy.carrental.mapper.ContractMapper;
import com.woniuxy.carrental.service.ContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 合同等功能的实现类
 */
@Service
public class ContractServiceImpl implements ContractService {

   @Autowired
    ContractMapper contractMapper;

   //合同添加
    @Override
    public void addContract(Contract contract) {
        contractMapper.addContract(contract);
    }

    //查询所有合同
    @Override
    public List<Contract> selectAllContract() {
        List<Contract> contracts = contractMapper.selectAllContract();
        return contracts;
    }

    //查寻该合同的客户信息
    @Override
    public Contract selectContractByUser(Integer contractId) {
        Contract contract = contractMapper.selectContractByUser(contractId);
        return contract;
    }

    //分页查询
    @Override
    public List<Contract> selectContractPage(int pageIndex, int pageSize, Contract contract) {
        List<Contract> contracts = contractMapper.selectContractPage(pageIndex, pageSize, contract);

        return contracts;
    }

    //查询总条数
    @Override
    public int selectContractCount() {
        int i = contractMapper.selectContractCount();
        return i;
    }

    //修改-延迟日期
    @Override
    public void updateByOverTime(Contract contract) {
      contractMapper.updateByOverTime(contract);
    }
}
